#!/usr/bin/env python
# -*- coding: utf-8 -*-

import pymongo


def connect_to_resys(day='2012-03-13'):
    host = '10.5.20.14'
    port = 27017
    user = 'groupbuyuser'
    passwd = 'a8a7h@ft6^%39'

    conn = pymongo.Connection(host, port)
    db = conn.groupbuy
    db.authenticate(user, passwd)
    coll = db['resys_log_%s' % (day)]
    return conn, coll


def get_query_count(coll, q):
    return coll.find(q).count()
